<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>Thread Support in Qt</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><p>
[Next: <a href="threads-starting.html">Starting Threads with QThread</a>]
</p>
<h1 class="title">Thread Support in Qt<br /><span class="subtitle" />
</h1>
<p>Qt provides thread support in the form of platform-independent threading classes, a thread-safe way of posting events, and signal-slot connections across threads. This makes it easy to develop portable multithreaded Qt applications and take advantage of multiprocessor machines. Multithreaded programming is also a useful paradigm for performing time-consuming operations without freezing the user interface of an application.</p>
<p>Earlier versions of Qt offered an option to build the library without thread support. Since Qt 4.0, threads are always enabled.</p>
<a name="topics" />
<h3>Topics:</h3>
<ul>
<li><a href="#recommended-reading">Recommended Reading</a></li>
<li><a href="#the-threading-classes">The Threading Classes</a></li>
<li><a href="threads-starting.html">Starting Threads with QThread</a></li>
<li><a href="threads-synchronizing.html">Synchronizing Threads</a></li>
<li><a href="threads-reentrancy.html">Reentrancy and Thread-Safety</a></li>
<li><a href="threads-qobject.html">Threads and QObjects</a></li>
<li><a href="threads-qtconcurrent.html">Concurrent Programming</a></li>
<li><a href="threads-modules.html">Thread-Support in Qt Modules</a></li>
</ul>
<a name="recommended-reading" />
<h3>Recommended Reading</h3>
<p>This document is intended for an audience that has knowledge of, and experience with, multithreaded applications. If you are new to threading see our Recommended Reading list:</p>
<ul>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0134436989/trolltech/t">Threads Primer: A Guide to Multithreaded Programming</a></li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0131900676/trolltech/t">Thread Time: The Multithreaded Programming Guide</a></li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/1565921151/trolltech/t">Pthreads Programming: A POSIX Standard for Better Multiprocessing</a></li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/1565922964/trolltech/t">Win32 Multithreaded Programming</a></li>
</ul>
<a name="the-threading-classes" />
<h3>The Threading Classes</h3>
<p>These classes are relevant to threaded applications.</p>
<p><table border="0" cellpadding="2" cellspacing="1" class="annotated" width="100%">
<tr class="odd" valign="top"><th><a href="qtconcurrentrun.html">Asynchronous Run</a></th><td>The &lt;QtConcurrentRun&gt; header provides a way to run a function in a separate thread.</td></tr>
<tr class="even" valign="top"><th><a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a></th><td>The &lt;QtConcurrentFilter&gt; header provides concurrent Filter and Filter-Reduce.</td></tr>
<tr class="odd" valign="top"><th><a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a></th><td>The &lt;QtConcurrentMap&gt; header provides concurrent Map and MapReduce.</td></tr>
<tr class="even" valign="top"><th><a href="qatomicint.html">QAtomicInt</a></th><td>Platform-independent atomic operations on integers</td></tr>
<tr class="odd" valign="top"><th><a href="qatomicpointer.html">QAtomicPointer</a></th><td>Template class that provides platform-independent atomic operations on pointers</td></tr>
<tr class="even" valign="top"><th><a href="qfuture.html">QFuture</a></th><td>Represents the result of an asynchronous computation</td></tr>
<tr class="odd" valign="top"><th><a href="qfuturesynchronizer.html">QFutureSynchronizer</a></th><td>Convenience class that simplifies QFuture synchronization</td></tr>
<tr class="even" valign="top"><th><a href="qfuturewatcher.html">QFutureWatcher</a></th><td>Allows monitoring a QFuture using signals and slots</td></tr>
<tr class="odd" valign="top"><th><a href="qmutex.html">QMutex</a></th><td>Access serialization between threads</td></tr>
<tr class="even" valign="top"><th><a href="qmutexlocker.html">QMutexLocker</a></th><td>Convenience class that simplifies locking and unlocking mutexes</td></tr>
<tr class="odd" valign="top"><th><a href="qreadlocker.html">QReadLocker</a></th><td>Convenience class that simplifies locking and unlocking read-write locks for read access</td></tr>
<tr class="even" valign="top"><th><a href="qreadwritelock.html">QReadWriteLock</a></th><td>Read-write locking</td></tr>
<tr class="odd" valign="top"><th><a href="qrunnable.html">QRunnable</a></th><td>The base class for all runnable objects</td></tr>
<tr class="even" valign="top"><th><a href="qsemaphore.html">QSemaphore</a></th><td>General counting semaphore</td></tr>
<tr class="odd" valign="top"><th><a href="qthread.html">QThread</a></th><td>Platform-independent threads</td></tr>
<tr class="even" valign="top"><th><a href="qthreadpool.html">QThreadPool</a></th><td>Manages a collection of QThreads</td></tr>
<tr class="odd" valign="top"><th><a href="qthreadstorage.html">QThreadStorage</a></th><td>Per-thread data storage</td></tr>
<tr class="even" valign="top"><th><a href="qwaitcondition.html">QWaitCondition</a></th><td>Condition variable for synchronizing threads</td></tr>
<tr class="odd" valign="top"><th><a href="qwritelocker.html">QWriteLocker</a></th><td>Convenience class that simplifies locking and unlocking read-write locks for write access</td></tr>
<tr class="even" valign="top"><th><a href="qtconcurrent.html">QtConcurrent</a></th><td>High-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives</td></tr>
</table></p>
<p><b>Note:</b> Qt's threading classes are implemented with native threading APIs; e.g., Win32 and pthreads. Therefore, they can be used with threads of the same native API.</p>
<p>
[Next: <a href="threads-starting.html">Starting Threads with QThread</a>]
</p>
<p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.7.1-5014f7c72a58 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt&#160;4.6.1</td></tr></table></div></address></body></html>